<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Jrebel License Server</title>
    <link rel="stylesheet" type="text/css" href="./src/page/normalize.css">
    <link rel="stylesheet" type="text/css" href="./src/page/demo.css">
    <!--必要样式-->
    <link rel="stylesheet" type="text/css" href="./src/page/component.css">
    <style type="text/css">#Layer1 {
        position: absolute;
        width: 100%;
        z-index: 2;
        top: 60%;
    }
    .STYLE3 {
        font-size: medium
    }</style>
</head>
<body>
<div class="container demo-1">
    <div class="content">
        <div id="large-header" class="large-header" style="height: 917px;">
            <canvas id="demo-canvas" width="1920" height="917"></canvas>
            <h1 class="main-title" style="height: 0;line-height: 65px;"><span style="font-size: 40px;">JetBrains License Server !</span><br>
                <span class="STYLE3"
                      style="font-size: small;line-height: 40px;">JetBrains Activation address was: <br><span
                        id="web-url"></span></span></h1>
        </div>
        <div id="Layer1">
            <nav class="codrops-demos"><a id="Copy" href="javascript:void(0);">复制</a></nav>
        </div>
    </div>
</div>
<script src="./src/page/TweenLite.min.js"></script>
<script src="./src/page/EasePack.min.js"></script>
<script src="./src/page/rAF.js"></script>
<script src="./src/page/demo-1.js"></script>
<script src="./src/jquery.min.js"></script>
<script src="./src/layer/layer.js"></script>
<script type="text/javascript">
    var str;

    var arrUrl = document.location.toString().split("?");
    console.log("当前页面地址",arrUrl);
    $('#web-url').html(arrUrl[0]);

    function api() {
        $.ajax({
            type: 'POST',
            url: '/info',
            dataType: 'json',
            data: {},
            contentType: 'application/json;charset=utf-8',
            success: function (res) {
                if (res.success) {
                    str = res.data.url + '/' + res.data.key;
                    console.log('ajax', str);
                }
            },
            error: function (error) {
                console.log(error);
            },
            complete: function () {
                $("#Copy").click(function () {
                    console.log('$("#Copy")', str);
                    var flag = str ? copyText(str) : false; //传递文本
                    layer.msg(flag ? "复制成功" : "复制失败");
                })
            }
        });
    }

    api();

    function copyText(text) {
        var flag;
        var textarea = document.createElement("input");//创建input对象
        var currentFocus = document.activeElement;//当前获得焦点的元素
        document.body.appendChild(textarea);//添加元素
        textarea.value = text;
        textarea.focus();
        if (textarea.setSelectionRange)
            textarea.setSelectionRange(0, textarea.value.length);//获取光标起始位置到结束位置
        else
            textarea.select();
        try {
            flag = document.execCommand("copy");//执行复制
        } catch (eo) {
            flag = false;
        }
        document.body.removeChild(textarea);//删除元素
        currentFocus.focus();
        return flag;
    }


    //禁止F12键盘事件
    document.addEventListener('keydown', function(event){
        return 123 != event.keyCode || (event.returnValue = false)
    });

</script>
</body>
</html>